from functools import wraps
from typing import Callable
from ...init.Global import Lock


def class_lock(func: Callable) -> Callable:
    @wraps(func)
    async def wrapper(self, *args, **kwargs):
        async with Lock:
            return await func(self, *args, **kwargs)

    return wrapper
